﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace laba_5
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        int n = 0, c = 0, cost = 0;
        string s;
        bool flag = false;
        int result = 0;
        int passangers = 0;
        bool alot;
        Bus B = new Bus();
        Taxi T = new Taxi();
        Subway S = new Subway();
        Calculate C = new Calculate();

        private void passangers_textBox_TextChanged(object sender, EventArgs e)
        {
           s = passangers_textBox.Text;
           int.TryParse(s, out n);
           if (n > 4)
               alot = true;
        }

        private void cost_textBox_TextChanged(object sender, EventArgs e)
        {
            s = cost_textBox.Text;
            int.TryParse(s, out cost);
        }

        private void subway_radioB_CheckedChanged(object sender, EventArgs e)
        {
            S.Set_cost(cost);
            result = C.Calc(n, S.Get_cost(), flag);
            
        }

        private void bus_radioB_CheckedChanged(object sender, EventArgs e)
        {
            B.Set_cost(cost);
            result = C.Calc(n, B.Get_cost(), flag);
        }

        private void taxi_radioB_CheckedChanged(object sender, EventArgs e)
        {
            flag = true;
            T.Set_cost(cost);
            result = C.Calc(n, T.Get_cost(), flag);
        }

        private void result_but_Click(object sender, EventArgs e)
        {
            if ((alot == true)&&(flag==true))
                result_textBox.Text = "В такси больше 4 человек не поместится."+ Environment.NewLine + "Результат подсчитан для 4 человек. " + Environment.NewLine + result.ToString() + " руб.";
                
            else
                result_textBox.Text = result.ToString() +" руб.";
        }


 

      
        
    }
}
